package com.file;

import java.io.File;
import java.io.IOException;

public class TestDeleFile {
	static final String Suffix = "_";
	public static void main(String[] args) throws IOException {
		
		//File f = new File("E:\\pro\\workPro\\cx\\ecop");
		File f = new File("E:\\pro\\workPro\\cx\\newPro1");
		//System.out.println(f.getName());
		File[] temp = f.listFiles();
		for(int i =0; i<temp.length; i++) {
			//System.out.println(temp[i].getName());
			if(temp[i].isDirectory()) {
				
				if((getFileFix(temp[i].getName(),".").equals("svn"))){
					delete(temp[i].listFiles());
					System.out.println(temp[i].getAbsolutePath());
					temp[i].delete();
					break;
				}
				listFile(temp[i].listFiles(), 1);
				
			}
		}
		
		//listFile(f.listFiles(), 1);
	}
	
	static void listFile(File[] f, int n) throws IOException {
		String s = "";
		for(int i = 0; i<n; i++ ) {
			s +="    ";
		}
		
		for(int j=0; j<f.length; j++) {
			//System.out.println(s + f[j].getName());
			if(f[j].isDirectory()) {
				
				if((getFileFix(f[j].getName(),".").equals("svn"))){
					delete(f[j].listFiles());
					System.out.println(f[j].getAbsolutePath());
					f[j].delete();
					break;
				}
				listFile(f[j].listFiles(), n+1);
				
			}
		}
		
	}
	
	static void delete(File[] f){
		for(int j=0; j<f.length; j++) {
			//System.out.println(s + f[j].getName());
			if(f[j].isDirectory()) {
				delete(f[j].listFiles());
				System.out.println(f[j].getAbsolutePath());
				f[j].delete();
			}else{
				System.out.println(f[j].getAbsolutePath());
				f[j].delete();
			}
		}
	}
	
	static String getFileFix(String fileName,String FixName){
		String fix ="";
		//System.out.println(FixName + "......");
		if(fileName.lastIndexOf(FixName)!=-1){
			fix = fileName.substring(fileName.lastIndexOf(FixName)+1,fileName.length());
		}
		//System.out.println(fix + "....nnn");
		return fix;
		
	}
	

}